Skip to content

Shrink no-op drop elaboration#157491

Open
cjgillot wants to merge 4 commits into
rust-lang:mainfrom
cjgillot:elaborate-drop-chain
Open

Shrink no-op drop elaboration#157491
cjgillot wants to merge 4 commits into
rust-lang:mainfrom
cjgillot:elaborate-drop-chain

Conversation

@cjgillot
Copy link
Copy Markdown
Contributor

@cjgillot cjgillot commented Jun 5, 2026

Drop elaboration can be very verbose, especially when locals are move-from by parts. This happens a lot with ? desugaring for instance.

I start from the example given in #157463 and attempt to shrink the generated code.

The remaining empty goto blocks come from resetting drop flags. The cost/benefit of the refactor was less interesting.

cjgillot added 4 commits June 5, 2026 15:59
These would become simple gotos anyway, so save the cost of creating such
blocks.
We are not modifying these blocks afterwards, so no need to create clean
ones each time.

Drive-by fix for async drops with enums.
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 5, 2026

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 5, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 5, 2026

r? @mejrs

rustbot has assigned @mejrs.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 21 candidates

@cjgillot
Copy link
Copy Markdown
Contributor Author

cjgillot commented Jun 5, 2026

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 5, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 5, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 5, 2026

☀️ Try build successful (CI)
Build commit: 0f76dc7 (0f76dc763580d699bfbe02f2ca1ca32d8db54243, parent: 39ec825c441918a4ae623a9b8840d1ccd446dcff)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (0f76dc7): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.7% [0.7%, 0.7%] 1
Regressions ❌
(secondary)
0.3% [0.2%, 0.4%] 3
Improvements ✅
(primary)
-0.7% [-1.2%, -0.1%] 10
Improvements ✅
(secondary)
-0.7% [-1.2%, -0.3%] 10
All ❌✅ (primary) -0.5% [-1.2%, 0.7%] 11

Max RSS (memory usage)

Results (primary 1.0%, secondary 0.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.7% [1.8%, 3.7%] 2
Regressions ❌
(secondary)
3.4% [3.4%, 3.4%] 1
Improvements ✅
(primary)
-2.4% [-2.4%, -2.4%] 1
Improvements ✅
(secondary)
-0.6% [-0.6%, -0.5%] 2
All ❌✅ (primary) 1.0% [-2.4%, 3.7%] 3

Cycles

Results (secondary -1.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.7% [2.7%, 2.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.8% [-4.0%, -2.1%] 3
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.0%, secondary -0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.4% [0.2%, 0.5%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.1%, -0.0%] 26
Improvements ✅
(secondary)
-0.0% [-0.1%, -0.0%] 38
All ❌✅ (primary) -0.0% [-0.1%, 0.5%] 28

Bootstrap: 514.669s -> 516.17s (0.29%)
Artifact size: 400.66 MiB -> 400.87 MiB (0.05%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 5, 2026
@saethlin
Copy link
Copy Markdown
Member

saethlin commented Jun 5, 2026

r? me

@rustbot rustbot assigned saethlin and unassigned mejrs Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants